package core.proto.rightwindow;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;

import javax.activation.DataHandler;
import javax.swing.JComponent;
import javax.swing.TransferHandler;

import core.proto.Util;

public class PostItTransferHandler extends TransferHandler {

	private static final long serialVersionUID = 2270879222196977159L;

	// Import methods. 
	public boolean canImport(TransferHandler.TransferSupport support) {
		Util.p("Can import?");
		return true;
	}

	public boolean importData(TransferHandler.TransferSupport support) {
		Util.p("importing data");
		return true;
	}
	
	final String postItMimeType = DataFlavor.javaJVMLocalObjectMimeType + ";class=\"" + PopupPanel.PostItEditor[].class.getName() + "\"";
	
	// Export methods. 
	public int getSourceActions(JComponent c) {
		if (c instanceof  PopupPanel.PostItEditor) {
			return MOVE;
		}
		return NONE;
	}
	
	public Transferable createTransferable(JComponent comp) {
		Util.p("create xferable");
		if (comp instanceof  PopupPanel.PostItEditor) {
			return new DataHandler(comp, postItMimeType);
		}
		return null;
	}
	
	protected void exportDone(JComponent comp, Transferable t, int action) {
	}
	
}
